"""
    在创建对象的时候，会隐式的调用类中的__init__()方法
    所以，可以通过显示声明__init__()方法，来简化对象中属性的赋值操作
"""
class Student1:
    name = None
    age = None
    gender = None

# 创建对象
student1 = Student1()
student1.name = '张三'

class Student2:
    name = None
    age = None
    gender = None

    def __init__(self, name, age, gender):
        self.name = name
        self.age = age
        self.gender = gender


student2 = Student2('张三', None, None)
print(student2.name)


class Student3:
    def __init__(self, name, age, gender):
        self.name = name
        self.age = age
        self.gender = gender

    def __str__(self):
        return f'name:{self.name}'

student3 = Student3('张三', 19, '男')
print(student3.gender)


